<?php

namespace common\models;

use Yii;

/**
 * This is the model class for table "graduation_eligible_audit".
 *
 * @property int $ID ID
 * @property int $BYSHID 毕业审核ID
 * @property int $ZYID 专业ID
 * @property string $ZYMC 专业名称
 * @property string $ZSLB 招生类别
 * @property string $JXXS 教学形式
 * @property string $XZ 学制
 * @property string $RXSJ 入学时间
 * @property string $TBR 填表人
 * @property string|null $SHR 审核人
 * @property string $TBRQ 填表日期
 *
 * @property GraduationAudit $bYSH
 * @property GraduationEligibleStudent[] $graduationEligibleStudents
 * @property Student[] $xSs
 */
class GraduationEligibleAudit extends \yii\db\ActiveRecord
{
    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return 'graduation_eligible_audit';
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['BYSHID', 'ZYID', 'ZYMC', 'ZSLB', 'JXXS', 'XZ', 'RXSJ', 'TBR', 'TBRQ'], 'required'],
            [['BYSHID', 'ZYID'], 'integer'],
            [['RXSJ', 'TBRQ'], 'safe'],
            [['ZYMC', 'TBR', 'SHR'], 'string', 'max' => 50],
            [['ZSLB', 'JXXS', 'XZ'], 'string', 'max' => 10],
            [['BYSHID'], 'exist', 'skipOnError' => true, 'targetClass' => GraduationAudit::className(), 'targetAttribute' => ['BYSHID' => 'ID']],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            'ID' => 'ID',
            'BYSHID' => '毕业审核ID',
            'ZYID' => '专业ID',
            'ZYMC' => '专业名称',
            'ZSLB' => '招生类别',
            'JXXS' => '教学形式',
            'XZ' => '学制',
            'RXSJ' => '入学时间',
            'TBR' => '填表人',
            'SHR' => '审核人',
            'TBRQ' => '填表日期',
        ];
    }

    /**
     * Gets query for [[BYSH]].
     *
     * @return \yii\db\ActiveQuery
     */
    public function getBYSH()
    {
        return $this->hasOne(GraduationAudit::className(), ['ID' => 'BYSHID'])->inverseOf('graduationEligibleAudits');
    }

    /**
     * Gets query for [[GraduationEligibleStudents]].
     *
     * @return \yii\db\ActiveQuery
     */
    public function getGraduationEligibleStudents()
    {
        return $this->hasMany(GraduationEligibleStudent::className(), ['BYZGSHID' => 'ID'])->inverseOf('bYZGSH');
    }

    /**
     * Gets query for [[XSs]].
     *
     * @return \yii\db\ActiveQuery
     */
    public function getXSs()
    {
        return $this->hasMany(Student::className(), ['ID' => 'XSID'])->viaTable('graduation_eligible_student', ['BYZGSHID' => 'ID']);
    }
}
